/**
 * 根据路由数组生成菜单树
 * @param {Array} routes - Vue Router 路由数组
 * @returns {Array} - 菜单数据
 */
export function generateMenuFromRoutes(routes) {
    return routes
        .filter(route => !route.meta || !route.meta.hidden) // 过滤隐藏项
        .map(route => {
            const menuItem = {
                name: route.name,
                path: route.path,
                label: route.meta?.title || route.name,
                children: []
            };

            if (route.children && route.children.length > 0) {
                menuItem.children = generateMenuFromRoutes(route.children);
            }

            return menuItem;
        });
}
export function generateMenu(routes) {
    return routes.filter(route => !route.meta?.hidden).map(route => {
        const item = {
            label: route.meta?.title || route.name,
            path: route.path,
            name: route.name,
            children: []
        };

        if (route.children && route.children.length > 0) {
            item.children = generateMenu(route.children);
        }

        return item;
    });
}